package com.example.administrator.zeycar.Widget;

import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.widget.PopupWindow;

/**
 * Created by Administrator on 2016/10/17 0017.
 */

public class CPopupWindow{

    private void showPop(PopupWindow popupWindow, View popView, View popLocationView){
        showPop(popupWindow, popView, popLocationView, 1);
    }

    private void showPop(PopupWindow popupWindow, View popView, View popLocationView, int heightMulriple){
        if(popupWindow == null) {
            popupWindow = new PopupWindow(popView, popLocationView.getWidth(), popLocationView.getHeight() * heightMulriple);
            popupWindow.setBackgroundDrawable(new BitmapDrawable());
            popupWindow.setOutsideTouchable(true);//点击外部隐藏切换码率菜单
            popupWindow.setFocusable(true);
        }
        int[] location = new int[2];
        popLocationView.getLocationInWindow(location);
        popupWindow.showAtLocation(popLocationView, Gravity.NO_GRAVITY, location[0], location[1] - popupWindow.getHeight());
    }
}
